class audioOutMod extends Mod
{

  audioOutMod(Mod tempParent, float tempBx, float tempBy, int tempIndex) {
    super(tempParent, tempBx, tempBy, tempIndex);
    img="audout";
    loadImg(img);
    name="out";
    minWx=48;
    minWy=48;
    iPs[ip]=new inPort(this, 3, "<");
    iPs[ip]=new inPort(this, 3, ">");
    updatePorts();
    leftOut.addInput(iPs[0].plug);
    rightOut.addInput(iPs[1].plug);
    ac.start();
  }
}
class audioSinMod extends Mod
{
  audioSinMod(Mod tempParent, float tempBx, float tempBy, int tempIndex) {
    super(tempParent, tempBx, tempBy, tempIndex);
    img="sin";
    loadImg(img);
    name="sine";
    minWx=40;
    minWy=48;
    iPs[ip]=new inPort(this, 3, "freq");
    iPs[ip]=new inPort(this, 2, "+");
    oPs[op]=new outPort(this, 3, "out");
    updatePorts();
    adder=new Add(ac, 1, iPs[1].floatV);
    iPs[0].plug.addInput(adder);
    wp = new WavePlayer(ac, iPs[0].plug, Buffer.SINE);
    oPs[0].plug.addInput(wp);
  }
  void update(int tempI) {
    if (tempI==130) {
      adder.setAdder(iPs[tempI-129].floatV);
    }
  }
  void destroy() {
    adder.kill();
    adder=null;
    wp.kill();
    wp=null;
  }
}


class audioSqrMod extends Mod
{
  audioSqrMod(Mod tempParent, float tempBx, float tempBy, int tempIndex) {
    super(tempParent, tempBx, tempBy, tempIndex);
    img="sqr";
    loadImg(img);
    name="square";
    minWx=40;
    minWy=48;
    iPs[ip]=new inPort(this, 3, "freq");
    iPs[ip]=new inPort(this, 2, "+");
    oPs[op]=new outPort(this, 3, "out");
    updatePorts();
    adder=new Add(ac, 1, iPs[1].floatV);
    iPs[0].plug.addInput(adder);
    wp = new WavePlayer(ac, iPs[0].plug, Buffer.SQUARE);
    oPs[0].plug.addInput(wp);
  }
  void update(int tempI) {
    println(iPs[tempI-129].floatV);
    if (tempI==130) {
      adder.setAdder(iPs[tempI-129].floatV);
    }
  }
  void destroy() {
    adder.kill();
    adder=null;
    wp.kill();
    wp=null;
  }
}

class audioGainMod extends Mod
{
  audioGainMod(Mod tempParent, float tempBx, float tempBy, int tempIndex) {
    super(tempParent, tempBx, tempBy, tempIndex);
    img="gain";
    loadImg(img);
    name="gain";
    minWx=48;
    minWy=64;
    iPs[ip]=new inPort(this, 3, "in");
    iPs[ip]=new inPort(this, 3, "mod");
    iPs[ip]=new inPort(this, 2, "+");
    oPs[op]=new outPort(this, 3, "out");
    updatePorts();
    adder=new Add(ac, 1, iPs[2].floatV);
    iPs[1].plug.addInput(adder);
    gn = new Gain(ac, 1, iPs[1].plug);
    gn.addInput(iPs[0].plug);
    oPs[0].plug.addInput(gn);
  }
 void update(int tempI) {
   if (tempI==131) {
      adder.setAdder(iPs[tempI-129].floatV);
    }
  }
  void destroy() {
    adder.kill();
    adder=null;
    gn.kill();
    gn=null;
  }
}
class audioPanMod extends Mod
{
  audioPanMod(Mod tempParent, float tempBx, float tempBy, int tempIndex) {
    super(tempParent, tempBx, tempBy, tempIndex);
    img="pan";
    loadImg(img);
    name="pan";
    minWx=48;
    minWy=64;
    iPs[ip]=new inPort(this, 3, "in");
    iPs[ip]=new inPort(this, 3, "pan");
    iPs[ip]=new inPort(this, 2, "+");
    oPs[op]=new outPort(this, 3, "<");
    oPs[op]=new outPort(this, 3, ">");
    updatePorts();
    adder=new Add(ac, 1, iPs[2].floatV);
    iPs[1].plug.addInput(adder);
    pn = new Panner(ac, iPs[1].plug);
    pn.addInput(iPs[0].plug);
    oPs[0].plug=new Plug(ac, pn, 0);
    oPs[1].plug=new Plug(ac, pn, 1);
  }
  void update(int tempI) {
    println(iPs[tempI-129].floatV);
    if (tempI==131) {
      adder.setAdder(iPs[tempI-129].floatV);
    }
  }
  void destroy() {
    adder.kill();
    adder=null;
    pn.kill();
    pn=null;
  }
}
/*
class audioFilterMod extends Mod
 {
 audioFilterMod(Mod tempParent, float tempBx, float tempBy, int tempIndex) {
 super(tempParent, tempBx, tempBy, tempIndex);
 //super(tempParent);
 img="lp";
 loadImg(img);
 name="lp";
 ip=3;
 op=1;
 wx=48;
 wy=64;
 iPs[0]=new inPort(this, 0, wy/4, 1, 3, "");
 iPs[1]=new inPort(this, 0, wy/2, 2, 2, "freq");
 iPs[2]=new inPort(this, 0, 3*wy/4, 3, 2, "q");
 oPs[0]=new outPort(this, wx, wy/2, 1, 3, "");
 bf = new BiquadFilter(ac, 1);
 plugIn=new Plug(ac);
 plugOut=new Plug(ac);
 bf.addInput(plugIn);
 plugOut.addInput(bf);
 }
 void go() {  
 
 //sendFloat(iPs[0].floatV*iPs[1].floatV, 0);
 }
 
 void update(int tempI) {
 println(iPs[tempI-129].floatV);
 if (tempI==130) {
 bf.setFreq(iPs[tempI-129].floatV);
 }
 if (tempI==131) {
 bf.setQ(iPs[tempI-129].floatV);
 }
 }
 }
 */
class audioGlideMod extends Mod
{
  audioGlideMod(Mod tempParent, float tempBx, float tempBy, int tempIndex) {
    super(tempParent, tempBx, tempBy, tempIndex);
    img="glide";
    loadImg(img);
    name="glide";
    minWx=40;
    minWy=48;
    iPs[ip]=new inPort(this, 2, "in");
    iPs[ip]=new inPort(this, 2, "ms");
    oPs[op]=new outPort(this, 3, "out");
    updatePorts();
    gl = new Glide(ac, 0, 0);
    oPs[0].plug.addInput(gl);
    iPs[1].setShowUnused(true);
  }
  void update(int tempI) {
    if (tempI==129) {
      gl.setValue(iPs[tempI-129].floatV);
    }
    if (tempI==130) {
      if (iPs[tempI-129].isUsed) {
        gl.setGlideTime(iPs[tempI-129].floatV);
      }
      else {
        gl.setGlideTime(0);
      }
    }
  }
  void destroy() {
    gl.kill();
    gl=null;
  }
}
class audioReverbMod extends Mod
{
  audioReverbMod(Mod tempParent, float tempBx, float tempBy, int tempIndex) {
    super(tempParent, tempBx, tempBy, tempIndex);
    img="reverb";
    loadImg(img);
    name="reverb";
    minWx=48;
    minWy=0;
    iPs[ip]=new inPort(this, 3, "in");
    iPs[ip]=new inPort(this, 2, "size");
    iPs[ip]=new inPort(this, 2, "early");
    iPs[ip]=new inPort(this, 2, "late");
    iPs[ip]=new inPort(this, 2, "damp");
    oPs[op]=new outPort(this, 3, "out");
    updatePorts();
    rvb = new Reverb(ac);
    rvb.addInput(iPs[0].plug);
    oPs[0].plug.addInput(rvb);
  }
void update(int tempI) {
    println(iPs[tempI-129].floatV);
    if (tempI==130) {
      rvb.setSize(iPs[tempI-129].floatV);
    }
    if (tempI==131) {
      rvb.setEarlyReflectionsLevel(iPs[tempI-129].floatV);
    }

    if (tempI==132) {
      rvb.setLateReverbLevel(iPs[tempI-129].floatV);
    }
    if (tempI==133) {
      rvb.setDamping(iPs[tempI-129].floatV);
    }
  }
  void destroy() {
    rvb.kill();
    rvb=null;
  }
}
class audioFFTMod extends Mod
{
  audioFFTMod(Mod tempParent, float tempBx, float tempBy, int tempIndex) {
    super(tempParent, tempBx, tempBy, tempIndex);
    img="fft";
    loadImg(img);
    name="fft";
    minWx=48;
    minWy=0;
    iPs[ip]=new inPort(this, 3, "in");
    iPs[ip]=new inPort(this, 2, "chunk");
    iPs[ip]=new inPort(this, 2, "hop");
    oPs[op]=new outPort(this, 4, "real");
    oPs[op]=new outPort(this, 4, "imag");
    updatePorts();
    sfs = new ShortFrameSegmenter(ac);
    sfs.addInput(iPs[0].plug);
    fft = new FFT();
    sfs.addListener(fft);
    //fft.addListener(oPs[0].plug);
    //oPs[0].plug.addListener(fft);
    //oPs[1].plug.addInput(fft.out);
    ac.out.addDependent(sfs);
  }
  void update(int tempI) {
    println(iPs[tempI-129].floatV);
    if (tempI==130) {
      sfs.setChunkSize(int(iPs[tempI-129].floatV));
    }
    if (tempI==131) {
      sfs.setHopSize(int(iPs[tempI-129].floatV));
    }
  }
  void destroy() {
    sfs.kill();
    sfs=null;
    fft.kill();
    fft=null;
  }
}

